package models

import "tuowei.com/common/models"

type CourseWare []struct {
	Name     string `json:"name"`
	Sort     int    `json:"sort"`
	Children []struct {
		Name    string `json:"name"`
		URL     string `json:"url"`
		Sort    int    `json:"sort"`
		UrlName string `json:"url_name"`
	} `json:"children"`
}

type SysCourseWare struct {
	models.Model
	CourseId          int    `json:"course_id" gorm:"comment:课程ID"`
	Name              string `json:"name" gorm:"comment:name"`
	CourseWare        string `json:"course_ware" gorm:"comment:课件链接地址"`
	Pid               int    `json:"pid" gorm:"comment:父级ID"`
	Level             int    `json:"level" gorm:"comment:等级"`
	Sort              int    `json:"sort" gorm:"comment:排序"`
	IsShow            int    `json:"is_show" comment:"是否显示"`
	IsContainExercise int    `json:"is_contain_exercise" comment:"是否含有练习题 -1-没有练习题 1-有练习题"`
	UrlName           string `json:"url_name" comment:"课件名称"`
	models.ControlBy
	models.ModelTime
}

func (s SysCourseWare) TableName() string {
	return "sys_course_ware"
}

func (s *SysCourseWare) Generate() models.ActiveRecord {
	o := *s
	return &o
}

func (s *SysCourseWare) GetId() interface{} {
	return s.Id
}

type CourseWareTree struct {
	Id                int              `gorm:"-" json:"id"`
	CourseId          int              `json:"course_id" gorm:"-"`
	Sort              int              `json:"sort" gorm:"-"`
	Name              string           `gorm:"-" json:"name"`
	Url               string           `json:"url" gorm:"-"`
	IsContainExercise int              `json:"is_contain_exercise"`
	Pid               int              `json:"pid,omitempty" gorm:"-"`
	IsShow            int              `json:"is_show,omitempty"`
	UrlName           string           `json:"url_name,omitempty"`
	Children          []CourseWareTree `gorm:"-" json:"children,omitempty"`
	WatchDuration     int              `json:"watchDuration,omitempty" gorm:"-"`
}
